﻿<UserControl x:Class="WhiteFlow.DevTrackingTool.UI.Views.CustomersListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:wfControls="clr-namespace:WhiteFlow.Wpf.Controls.Common;assembly=WhiteFlow.Wpf.Controls"
             xmlns:converters="clr-namespace:WhiteFlow.DevTrackingTool.UI.Converters"
             mc:Ignorable="d"
             d:DesignHeight="371" 
             d:DesignWidth="743">

    <UserControl.Resources>
        <converters:IsNullToBooleanConverter x:Key="IsNullToBooleanConverter" />
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <TextBlock Text="Customers List" 
                   Grid.Row="0"
                   Margin="20,0,0,0" 
                   FontSize="50" 
                   Foreground="{StaticResource ResourceKey=BlueFgBrush}" 
                   FontFamily="/WhiteFlow.DevTrackingTool.UI;Component/Resources/Fonts/#BIRTH OF A HERO" />

        <Grid Grid.Row="1">
            <DockPanel LastChildFill="True">
                <Border DockPanel.Dock="Top"
                        Padding="10">
                    <StackPanel Orientation="Horizontal">
                        <Button Cursor="Hand"
                                Background="Transparent"
                                Command="{Binding Path=AddCustomerCommand}"
                                Style="{StaticResource ResourceKey=HoverButtonStyle}">
                            <Button.Content>
                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                    <Border VerticalAlignment="Center">
                                        <wfControls:Bitmap Source="/WhiteFlow.DevTrackingTool.UI;Component/Resources/Icons/Application/pencil_add.png" />
                                    </Border>
                                    <TextBlock Text="Add a customer" 
                                               Margin="5,0,0,0"
                                               VerticalAlignment="Center" />
                                </StackPanel>
                            </Button.Content>
                        </Button>
                        <Button Cursor="Hand"
                                Background="Transparent"
                                Command="{Binding Path=DeleteSelectedCustomerCommand}"
                                Style="{StaticResource ResourceKey=HoverButtonStyle}">
                            <Button.Content>
                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                    <Border VerticalAlignment="Center">
                                        <wfControls:Bitmap Source="/WhiteFlow.DevTrackingTool.UI;Component/Resources/Icons/Application/pencil_delete.png" />
                                    </Border>
                                    <TextBlock Text="Delete selected customer" 
                                               Margin="5,0,0,0"
                                               VerticalAlignment="Center" />
                                </StackPanel>
                            </Button.Content>
                        </Button>
                    </StackPanel>
                </Border>

                <DataGrid ItemsSource="{Binding Path=OwnerWorksheetViewModel.Worksheet.Customers}"
                          CanUserAddRows="False"
                          CanUserReorderColumns="False"
                          CanUserResizeRows="False"
                          CanUserSortColumns="False"
                          SelectionUnit="CellOrRowHeader"
                          AutoGenerateColumns="False">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="Customer Name" Binding="{Binding Path=Name}" Width="auto" />
                        <DataGridTextColumn Header="Description" Binding="{Binding Path=Description}" Width="*" />
                    </DataGrid.Columns>
                </DataGrid>

                <DockPanel.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path=OwnerWorksheetViewModel.Worksheet.Customers, Mode=OneWay, Converter={StaticResource ResourceKey=IsNullToBooleanConverter}}" Value="True">
                                <Setter Property="Control.Visibility" Value="Collapsed" />
                                <Setter Property="Control.Opacity" Value="0" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Path=OwnerWorksheetViewModel.Worksheet.Customers, Mode=OneWay, Converter={StaticResource ResourceKey=IsNullToBooleanConverter}}" Value="False">
                                <Setter Property="Control.Visibility" Value="Visible" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </DockPanel.Style>
            </DockPanel>

            <Border Margin="20">
                <StackPanel Orientation="Vertical">
                    <TextBlock Text="This worksheet does not contain a customers list yet."
                               Foreground="Black" />
                    <Button Margin="0,20,0,0" 
                            Cursor="Hand"
                            Background="Transparent"
                            Command="{Binding Path=CreateCustomersListCommand}"
                            Style="{StaticResource ResourceKey=HoverButtonStyle}">
                        <Button.Content>
                            <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                <Border VerticalAlignment="Center">
                                    <wfControls:Bitmap Source="/WhiteFlow.DevTrackingTool.UI;Component/Resources/Icons/Application/to_do_list.png" />
                                </Border>
                                <TextBlock Text="Create a customers list for this worksheet" 
                                           Margin="5,0,0,0"
                                           VerticalAlignment="Center" />
                            </StackPanel>
                        </Button.Content>
                    </Button>
                </StackPanel>

                <Border.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path=OwnerWorksheetViewModel.Worksheet.Customers, Mode=OneWay, Converter={StaticResource ResourceKey=IsNullToBooleanConverter}}" Value="True">
                                <Setter Property="Control.Visibility" Value="Visible" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Path=OwnerWorksheetViewModel.Worksheet.Customers, Mode=OneWay, Converter={StaticResource ResourceKey=IsNullToBooleanConverter}}" Value="False">
                                <Setter Property="Control.Visibility" Value="Collapsed" />
                                <Setter Property="Control.Opacity" Value="0" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Border.Style>
            </Border>
        </Grid>
    </Grid>

</UserControl>